import Index from '@/pages/weblog/index.vue'
import Login from '@/pages/admin/login.vue'
import AdminIndex from '@/pages/admin/index.vue'
import Admin from '@/layouts/admin/admin.vue'
import AdminArticleList from '@/pages/admin/article-list.vue'
import AdminCategoryList from '@/pages/admin/category-list.vue'
import AdminTagList from '@/pages/admin/tag-list.vue'
import AdminBlogSetting from '@/pages/admin/blog-setting.vue'
import ArchiveList from '@/pages/weblog/archive-list.vue'
import CategoryList from '@/pages/weblog/category-list.vue'
import CategoryArticleList from '@/pages/weblog/category-article-list.vue'
import TagList from '@/pages/weblog/tag-list.vue'
import TagArticleList from '@/pages/weblog/tag-article-list.vue'
import ArticleDetail from '@/pages/weblog/article-detail.vue'
import NotFound from '@/pages/weblog/404.vue'
import { createRouter, createWebHashHistory } from 'vue-router'

//统一声明所有路由
const routes = [
    {
        path: '/',//路由地址
        component: Index,//对应组件
        meta: {//路由元信息
            title: 'DC-Weblog 首页'
        }
    },
    {
        path: '/archive/list', // 归档页
        component: ArchiveList,
        meta: { // meta 信息
            title: 'DC-Weblog 归档页'
        }
    },
    {
        path: '/category/list', // 分类
        component: CategoryList,
        meta: { // meta 信息
            title: 'DC-Weblog 分类页'
        }
    },
    {
        path: '/tag/list', // 标签
        component: TagList,
        meta: { // meta 信息
            title: 'DC-Weblog 标签页'
        }
    },
    {
        path: '/article/:articleId', // 文章详情页
        component: ArticleDetail ,
        meta: { // meta 信息
            title: 'DC-Weblog 文章详情页'
        }
    },
    {
        path: '/category/article/list', // 分类文章页
        component: CategoryArticleList ,
        meta: { // meta 信息
            title: 'DC-Weblog 分类文章页'
        }
    }, {
        path: '/tag/article/list', // 分类文章页
        component: TagArticleList ,
        meta: { // meta 信息
            title: 'DC-Weblog 标签文章页'
        }
    },
    {
        path: '/login',
        component: Login,
        meta: {//路由元信息
            title: 'DC-Weblog 登录'
        }
    },
    {
        path: '/:pathMatch(.*)*',
        name: 'NotFound',
        component: NotFound,
        meta: {
            title: '404 页'
        }
    },
    {
        path: '/admin',
        component: Admin,
        children: [
            {
                path: "/admin/index",
                component: AdminIndex,
                meta: {
                    title: '仪表盘'
                }
            },
            {
                path: "/admin/article/list",
                component: AdminArticleList,
                meta: {
                    title: '文章管理'
                }
            },
            {
                path: "/admin/category/list",
                component: AdminCategoryList,
                meta: {
                    title: '分类管理'
                }
            },
            {
                path: "/admin/tag/list",
                component: AdminTagList,
                meta: {
                    title: '标签管理'
                }
            },
            {
                path: "/admin/blog/setting",
                component: AdminBlogSetting,
                meta: {
                    title: '博客设置'
                }
            },
        ]
    }
]

//创建路由
const router = createRouter({
    //路由模式 
    history: createWebHashHistory(),
    routes
})


// 导出路由
export default router